home *** CD-ROM | disk | FTP | other *** search
/ TOS Silver 2000 / TOS Silver 2000.iso / Anwendun / LUNA152A / _ENGLISH / MODULES / COMMENTS.S < prev    next >
Encoding:
Text File  |  1999-10-07  |  2.4 KB  |  91 lines

  1.  
  2. ; Comments.fm  (c)1999 Richard Gordon Faika
  3.  
  4. ; Inserts a comment character (the semicolon), for assembler, for instance,
  5. ; at the start of the text string to be filtered.
  6.  
  7. ; --------------------------------------------------------------------
  8. ; Get parameters
  9. ; --------------------------------------------------------------------
  10.             move    4(sp),d0                ; Get function number
  11.             move.l    6(sp),a0            ; Get text-string address
  12.             move.l    10(sp),a1        ; Get address of working buffer
  13.             move    14(sp),d1            ; Get length of string
  14.          ; move    16(sp),d2            ; Length of working buffer is not needed
  15.             
  16.             tst        d0                    ; Filter?
  17.             beq        filter
  18.  
  19.             cmpi    #1,d0
  20.             bne        case1 
  21.             bra        GetInfo            ; Info
  22. case1:        
  23.             cmpi    #2,d0
  24.             bne        case2 
  25.             bra        ModInit            ; Init
  26. case2:        
  27.             cmpi    #3,d0
  28.             bne        noFunc
  29.             bra        ModExit            ; Exit
  30.  
  31. ModInit:    
  32.             clr.l    d0                        ; There is nothing to initialise
  33.             rts
  34. ModExit:
  35.             clr.l    d0                        ; There is also nothing to deinitialise
  36.             rts
  37.  
  38. GetInfo:    lea.l    info(pc),a0            ; Return pointer to info-text
  39.             move.l    a0,d0
  40.             rts
  41.  
  42. noFunc:    moveq.l    #-32,d0
  43.             rts
  44.  
  45.  
  46.  
  47. ; --------------------------------------------------------------------
  48. ; Filter routine
  49. ; --------------------------------------------------------------------
  50.  
  51. filter:    tst        d1                    ; Test string length
  52.             beq        exit0                ; If zero, do nothing
  53.  
  54.             move.b    #';',(a1)+            ; Insert comment character
  55.  
  56. ; Copy remaining text
  57.  
  58.             lsr        #1,d1                ; /2
  59.             bcc.b        go2                ; Divisible by 2?
  60.             move.b    (a0)+,(a1)+            ; No, so first character
  61.     go2:        
  62.             lsr        #1,d1                ; /2
  63.             bcc        go_all                ; Divisible by 2?
  64.             bra        go24                ; No, so first two characters
  65.     go4:        
  66.             move.b    (a0)+,(a1)+
  67.             move.b    (a0)+,(a1)+
  68.     go24:        
  69.             move.b    (a0)+,(a1)+
  70.             move.b    (a0)+,(a1)+
  71.     go_all:            
  72.             dbra    d1,go4                ; Always 4 at a time
  73.  
  74.  
  75.  
  76.             clr.b    (a1)                ; Null-terminate string
  77.     exit:    move.l    #1,d0                ; 0 = OK
  78.             rts
  79. exit0:    clr.l    d0
  80.             rts
  81.  
  82.  
  83.  
  84. workbuf:    dc.l    0
  85. info:        dc.b    ' Comments',0        ; Module info for popup, max. 24 chars.+nullbyte
  86.             dc.b    'Richard Gordon Faika',0    ; Author's name, max. 20 chars.+nullbyte
  87.             dc.b    'THE MODULE INSERTS A SEMICOLON AT',0    ; Max. 40 characters+nullbyte
  88.             dc.b    'THE START OF A SELECTED TEXT STRING',0    ; Max. 40 characters+nullbyte
  89.             dc.b    'AND SO TURNS IT INTO A COMMENT IN, SAY,',0    ; Max. 40 characters+nullbyte
  90.             dc.b    'ASSEMBLER SOURCECODE.',0    ; Max. 40 characters+nullbyte
  91.